//
//  TTIM_CouponCardCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/9/3.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "TTIM_CouponCardCell.h"
#import "IM_CustomCouponModel.h"

@implementation TTIM_CouponCardCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //初始化
        self.contentView.backgroundColor = [UIColor clearColor];

        _couponbgIV = [[UIImageView alloc]init];
        [self.container addSubview:_couponbgIV];
        
        _cutLab = [[UILabel alloc]init];
        _cutLab.font = [UIFont systemFontOfSize:15];;
        _cutLab.textColor = UIColorHex(0xffffff);
        [self.container addSubview:_cutLab];
        
        _scoTypeLab = [[UILabel alloc]init];
        [self.container addSubview:_scoTypeLab];
        _scoTypeLab.font = [UIFont systemFontOfSize:12];;
        _scoTypeLab.textColor = UIColorHex(0xffffff);
        
        _conditionLab = [[UILabel alloc]init];
        [self.container addSubview:_conditionLab];
        _conditionLab.font = [UIFont systemFontOfSize:9];;
        _conditionLab.textColor = UIColorHex(0xffffff);
        
        _rightLab = [[UILabel alloc]init];
        [self.container addSubview:_rightLab];
        _rightLab.font = [UIFont systemFontOfSize:12];
        _rightLab.textColor = UIColorHex(0xffffff);
        _rightLab.textAlignment = NSTextAlignmentCenter;
        _rightLab.numberOfLines = 0;
        
        
        [self.couponbgIV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.right.bottom.mas_equalTo(0);
        }];
        
        [self.cutLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.top.mas_equalTo(15);
        }];
        
        [self.conditionLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.cutLab.mas_right).offset(5);
            make.bottom.mas_equalTo(self.cutLab.mas_bottom);
        }];
        
        [self.scoTypeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.cutLab);
            make.top.mas_equalTo(self.cutLab.mas_bottom).offset(5);
        }];
        
        [self.rightLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(0);
            make.right.mas_equalTo(-18);
        }];
        
    }
    return self;
}

- (void)fillWithData:(TTIM_CouponCardCellData *)data {
    [super fillWithData:data];
    self.customData = data;
    
    NSDictionary *ext = data.model.ext;
    IM_CustomCouponModel *model = [IM_CustomCouponModel modelWithDictionary:ext];
    
    _couponbgIV.image = [UIImage imageNamed:@"TUI_chat_coupon_no"];
    self.rightLab.text = @"立即\n领取";

    self.cutLab.text = [NSString stringWithFormat:@"¥%@",[Utilities changeDoubleToString:model.scoCut]];
    self.conditionLab.text = [NSString stringWithFormat:@"满%@可用",[Utilities changeDoubleToString:model.scoFull]];
    self.scoTypeLab.text = model.scoTypeName;
}




@end
